package pers.qianyu.month_202012.date_20201208;

/**
 * 283. 移动零
 * https://leetcode-cn.com/problems/move-zeroes/
 *
 * @author mizzle rain
 * @date 2020-12-08 22:58
 */
public class MoveZeroes {
    public void moveZeroes(int[] nums) {
        if (nums == null) {
            return;
        }
        int slow = 0, fast = 0;
        while (fast < nums.length) {
            if (nums[fast] != 0) {
                nums[slow] = nums[fast];
                slow++;
            }
            fast++;
        }
        for (int i = slow; i < nums.length; i++) {
            nums[i] = 0;
        }
    }
}
